var api = require("../../api.js"), app = getApp();
Page({
  data: {
    
  },
  onLoad: function (e) {
    var that = this;
    app.pageOnLoad(this);
    wx.getSetting({
      success: function (res) {
        if (res.authSetting['scope.userInfo']) {
          // 已经授权，可以直接调用 getUserInfo 获取头像昵称
          wx.getUserInfo({
            lang: 'zh_CN',
            success: function (res) {
              that.setData({
                userInfo: res.userInfo
              });
              console.log(that.data.userInfo);
            }
          })
        }
      }
    })
  },
  loadData: function (e) {
    var a = this;
    a.setData({
      store: wx.getStorageSync("store")
    });
    var t = wx.getStorageSync("pages_user_user");
    t && a.setData(t), app.request({
      url: api.user.index,
      success: function (e) {
        0 == e.code && (a.setData(e.data), wx.setStorageSync("pages_user_user", e.data),
          wx.setStorageSync("share_setting", e.data.share_setting), wx.setStorageSync("user_info", e.data.user_info),
          console.log(e.data));
      }
    });
    console.log(a.data.user_info);
  },
  onReady: function () { },
  onShow: function () {
    app.pageOnShow(this);
    this.loadData();
  }
});